<?php

declare(strict_types=1);

use Hyperf\DbConnection\Db;
use Hyperf\Database\Seeders\Seeder;

class AdminSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        if (!Db::table('admin')->where('is_admin', 1)->exists()) {
            Db::table('admin')->insert([
                'nickname' => 'Administrator',
                'username' => 'admin',
                'password' => password_hash('123456', PASSWORD_BCRYPT),
                'is_admin' => 1,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s')
            ]);
        }
    }
}
